package com.lqa.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lqa.mapper.EbProductMapper;
import com.lqa.model.EbProduct;
import com.lqa.service.EbProductCategoryService;
import com.lqa.service.EbProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/product")
public class EbProductController {
    @Autowired
    private EbProductService ebProductService;
    @RequestMapping("/detail")
    public String detail(Model model,int epId){
        EbProduct ebProduct = ebProductService.detail(epId);
        model.addAttribute("product",ebProduct);
        return "product-view";
    }
    @RequestMapping("/add_car")


    public String addCar(int epId, HttpServletRequest request) {
        //1.TODO 调用service将商品加入购物车
        ebProductService.addCar(epId, request);
        //2/TODO 绑定数据到model---数据
        //不需要因为在service已经将数据放到session中了
        //3.TODO 返回view--html
        return "shopping" ;

    }

}